//
//  MCThdPartyViewController.m
//  ZXZX
//
//  Created by menhao on 2018/6/14.
//  Copyright © 2018年 TLYL01. All rights reserved.
//

#import "MCThdPartyViewController.h"
#import <WebKit/WebKit.h>
#import "MCKefuModel.h"
#import "MCMailNavigationController.h"

@interface MCThdPartyViewController ()<WKNavigationDelegate>

@property (nonatomic,strong) MCKefuModel *model;
@property (nonatomic,weak) WKWebView *web;

@end

@implementation MCThdPartyViewController

- (void)viewDidLoad {
    
    [super viewDidLoad];
    self.navigationItem.title = _mytitle;
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.view.backgroundColor = [UIColor whiteColor];
    WKWebView *web = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, G_SCREENWIDTH, G_SCREENHEIGHT - kStatusBarAndNavigationBarHeight)];
    web.navigationDelegate = self;
    [self.view addSubview:web];
    self.web = web;
    [self.web loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.url]]];
    web.backgroundColor = [UIColor whiteColor];
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
//    self.navigationController.navigationBar.hidden = YES;
}
- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
//    self.navigationController.navigationBar.hidden = NO;
}
- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation{
    
    [BKIndicationView showInView:self.view];
}
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation{
    
    [BKIndicationView dismiss];
}

- (void)webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigation withError:(NSError *)error{
    if (error.code == -1001 ||error.code == 4) {
        
        [BKIndicationView dismiss];
        [SVProgressHUD showInfoWithStatus:@"页面加载超时！"];
    } else {
        [BKIndicationView dismiss];
    }
    
    
}
- (void)btnClick{
    [self dismissViewControllerAnimated:YES completion:nil];
}


@end
